const socketConnectMap = new Map();

function addConnect(username, socket) {
    if (socketConnectMap.has(username)) {
        console.log('already connected');
        return false;
    }
    socketConnectMap.set(username, socket);
    return true;
}

function deleteConnect(username) {
    if (!socketConnectMap.has(username)) {
        console.log('no such connected');
        return false;
    }
    socketConnectMap.delete(username);
    console.log('delete successfully');
    return true;
}

function getUserSocket(username) {
    return socketConnectMap.get(username);
}
module.exports = { addConnect, deleteConnect, getUserSocket };